#include "StdAfx.h"
#include "Interface.h"

Interface::Interface(void)
{
}

Interface::~Interface(void)
{
}

void Interface::CGalTriangulate(const HWND & hwnd, const POINT & shift)
{
  CGTriangulate cg;

  const Face *face;
  FaceFactory ff;
  edgeForIterator it;

  if(ff.SetFirtsEl())
  {
    while( (face = ff.GetNextEl()) != NULL)
    {
      cg.Clear();
      for(it = (edgeForIterator &)face->begin();
          it != (edgeForIterator &)face->end();
          it++)
      {
        cg.AddCCWPoint(((figureEdge *)(*it))->_begin);
      }
      cg.Triangulate();
      cg.Draw(hwnd, shift);
      Sleep(1000);
    }
  }

  //cg.AddCCWPoint(*vt);
  //
}

void Interface::DrawFaces(const HWND & hwnd, const POINT & shift)
{
  FaceFactory ff;
  ff.Draw(hwnd, shift);
}

void Interface::Triangulate(const HWND & hwnd, const POINT & shift)
{
  const Face *face;
  FaceFactory ff;
  Triangulation tt;
  TriangleFactory tf;

  tf.Clear();
  if(ff.SetFirtsEl())
  {
    while( (face = ff.GetNextEl()) != NULL)
    {
      tt.SetFace(*face);
      tt.Triangulate();
      tt.TriangleExtract(hwnd, shift);
    }
  }
}

void Interface::DrawTriangles(const HWND & hwnd, const POINT & shift)
{
  TriangleFactory tf;
  tf.DrawAll(hwnd, shift);
}

const long double & Interface::GetArea(int scale, int xres, int yres)
{
  TriangleFactory tf;
  long double area = 0.0;

  _ASSERT(scale != 0);
  _ASSERT(xres != 0);
  _ASSERT(yres != 0);
  //We have to check if the both action
  //1.Face'ing
  //2.Triangulation
  //were done succesfully
  //Afterthat we can return the area 
  
  return(tf.CalculateField(scale, xres, yres));
}
